# python中yield的用法
# https://blog.csdn.net/mieleizhi0522/article/details/82142856


def foo():
    print("starting...")
    while True:
        res = yield 4
        print("res:", res)


def printFun():
    print("running")


if __name__ == '__main__':
    g = foo()  # 带有yield关键词的函数不会直接调用
    p = printFun()
    print(next(g))  # next()函数才开始调用foo()
    print("*"*20)
    print(g.send(7))    # send()函数可以对foo()传入值


if __name__ == '__main__#':
    g = foo()
    print(next(g))
    print("*" * 20)
    print(next(g))  # 下一个next()函数会从上一个yield中断继续执行。
